from django.shortcuts import render
from verifications.libs.captcha.captcha import captcha
from django_redis import get_redis_connection
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse


# Create your views here.
# 图片验证码
def get_img_code(request, uuid):
    """
    @param request:
    @param uuid: 通用识别码
    @param return: image
    """
    text, image = captcha.generate_captcha()
    redis_conn = get_redis_connection('verify_code')
    redis_conn.setex('img_%s' % uuid, '300', text)
    return HttpResponse(image, content_type='image/jpg')